package com.ftx.controller.pc;

import com.ftx.common.enums.ArticleStatusEnum;
import com.ftx.domain.alias.PageCondition;
import com.ftx.domain.content.NumContent;
import com.ftx.domain.query.ArticleQuery;
import com.ftx.service.article.ArticleService;
import com.ftx.service.index.IndexService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by fengtingxin on 2019/6/10.
 */
@Controller
@RequestMapping(value = "/home")
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    @Resource
    private ArticleService articleService;

    @RequestMapping("/index")
    public ModelAndView index(ModelMap model) {
        PageCondition pageCondition = new PageCondition(NumContent.FIRST_PAGE,1);
        ArticleQuery articleQuery = new ArticleQuery();
        articleQuery.setArticleStatus(ArticleStatusEnum.RELEASE_COMPLETED.getKey());
        model.addAttribute("page", articleService.pageByCondition(pageCondition,articleQuery));
        return new ModelAndView("/front/index", model);
    }
}
